'use strict';
var k = "function" == typeof Object.defineProperties ? Object.defineProperty : function (a, b, c) {
        a != Array.prototype && a != Object.prototype && (a[b] = c.value)
    },
    l = "undefined" != typeof window && window === this ? this : "undefined" != typeof global && null != global ? global : this;
function m() {
    m = function () {
    };
    l.Symbol || (l.Symbol = n)
}
var n = function () {
    var a = 0;
    return function (b) {
        return "jscomp_symbol_" + (b || "") + a++
    }
}();
function p() {
    m();
    var a = l.Symbol.iterator;
    a || (a = l.Symbol.iterator = l.Symbol("iterator"));
    "function" != typeof Array.prototype[a] && k(Array.prototype, a, {
        configurable: !0,
        writable: !0,
        value: function () {
            return r(this)
        }
    });
    p = function () {
    }
}
function r(a) {
    var b = 0;
    return t(function () {
        return b < a.length ? {done: !1, value: a[b++]} : {done: !0}
    })
}
function t(a) {
    p();
    a = {next: a};
    a[l.Symbol.iterator] = function () {
        return this
    };
    return a
}
function u(a) {
    p();
    var b = a[Symbol.iterator];
    return b ? b.call(a) : r(a)
}
function w(a, b) {
    if (b) {
        var c = l;
        a = a.split(".");
        for (var e = 0; e < a.length - 1; e++) {
            var d = a[e];
            d in c || (c[d] = {});
            c = c[d]
        }
        a = a[a.length - 1];
        e = c[a];
        b = b(e);
        b != e && null != b && k(c, a, {configurable: !0, writable: !0, value: b})
    }
}
w("Promise", function (a) {
    function b(a) {
        this.c = 0;
        this.h = void 0;
        this.a = [];
        var b = this.e();
        try {
            a(b.resolve, b.reject)
        } catch (q) {
            b.reject(q)
        }
    }

    function c() {
        this.a = null
    }

    function e(a) {
        return a instanceof b ? a : new b(function (b) {
            b(a)
        })
    }

    if (a)return a;
    c.prototype.c = function (a) {
        null == this.a && (this.a = [], this.g());
        this.a.push(a)
    };
    c.prototype.g = function () {
        var a = this;
        this.e(function () {
            a.j()
        })
    };
    var d = l.setTimeout;
    c.prototype.e = function (a) {
        d(a, 0)
    };
    c.prototype.j = function () {
        for (; this.a && this.a.length;) {
            var a = this.a;
            this.a = [];
            for (var b = 0; b < a.length; ++b) {
                var c = a[b];
                delete a[b];
                try {
                    c()
                } catch (v) {
                    this.h(v)
                }
            }
        }
        this.a = null
    };
    c.prototype.h = function (a) {
        this.e(function () {
            throw a;
        })
    };
    b.prototype.e = function () {
        function a(a) {
            return function (f) {
                c || (c = !0, a.call(b, f))
            }
        }

        var b = this, c = !1;
        return {resolve: a(this.n), reject: a(this.g)}
    };
    b.prototype.n = function (a) {
        if (a === this) this.g(new TypeError("A Promise cannot resolve to itself")); else if (a instanceof b) this.o(a); else {
            a:switch (typeof a) {
                case "object":
                    var f = null != a;
                    break a;
                case "function":
                    f = !0;
                    break a;
                default:
                    f = !1
            }
            f ? this.m(a) : this.j(a)
        }
    };
    b.prototype.m = function (a) {
        var b = void 0;
        try {
            b = a.then
        } catch (q) {
            this.g(q);
            return
        }
        "function" == typeof b ? this.p(b, a) : this.j(a)
    };
    b.prototype.g = function (a) {
        this.k(2, a)
    };
    b.prototype.j = function (a) {
        this.k(1, a)
    };
    b.prototype.k = function (a, b) {
        if (0 != this.c)throw Error("Cannot settle(" + a + ", " + b | "): Promise already settled in state" + this.c);
        this.c = a;
        this.h = b;
        this.l()
    };
    b.prototype.l = function () {
        if (null != this.a) {
            for (var a = this.a, b = 0; b < a.length; ++b)a[b].call(), a[b] = null;
            this.a = null
        }
    };
    var g = new c;
    b.prototype.o = function (a) {
        var b = this.e();
        a.i(b.resolve, b.reject)
    };
    b.prototype.p = function (a, b) {
        var f = this.e();
        try {
            a.call(b, f.resolve, f.reject)
        } catch (v) {
            f.reject(v)
        }
    };
    b.prototype.then = function (a, f) {
        function c(a, b) {
            return "function" == typeof a ? function (b) {
                try {
                    e(a(b))
                } catch (I) {
                    d(I)
                }
            } : b
        }

        var e, d, h = new b(function (a, b) {
            e = a;
            d = b
        });
        this.i(c(a, e), c(f, d));
        return h
    };
    b.prototype.catch = function (a) {
        return this.then(void 0, a)
    };
    b.prototype.i = function (a, b) {
        function f() {
            switch (c.c) {
                case 1:
                    a(c.h);
                    break;
                case 2:
                    b(c.h);
                    break;
                default:
                    throw Error("Unexpected state: " + c.c);
            }
        }

        var c = this;
        null == this.a ? g.c(f) : this.a.push(function () {
            g.c(f)
        })
    };
    b.resolve = e;
    b.reject = function (a) {
        return new b(function (b, c) {
            c(a)
        })
    };
    b.race = function (a) {
        return new b(function (b, c) {
            for (var f = u(a), d = f.next(); !d.done; d = f.next())e(d.value).i(b, c)
        })
    };
    b.all = function (a) {
        var c = u(a), d = c.next();
        return d.done ? e([]) : new b(function (a, b) {
            function f(b) {
                return function (c) {
                    h[b] = c;
                    q--;
                    0 == q && a(h)
                }
            }

            var h = [], q = 0;
            do h.push(void 0), q++, e(d.value).i(f(h.length - 1), b), d = c.next(); while (!d.done)
        })
    };
    return b
});
function x(a, b) {
    return Object.prototype.hasOwnProperty.call(a, b)
}
w("WeakMap", function (a) {
    function b(a) {
        this.a = (g += Math.random() + 1).toString();
        if (a) {
            m();
            p();
            a = u(a);
            for (var b; !(b = a.next()).done;)b = b.value, this.set(b[0], b[1])
        }
    }

    function c(a) {
        x(a, d) || k(a, d, {value: {}})
    }

    function e(a) {
        var b = Object[a];
        b && (Object[a] = function (a) {
            c(a);
            return b(a)
        })
    }

    if (function () {
            if (!a || !Object.seal)return !1;
            try {
                var b = Object.seal({}), c = Object.seal({}), d = new a([[b, 2], [c, 3]]);
                if (2 != d.get(b) || 3 != d.get(c))return !1;
                d.delete(b);
                d.set(c, 4);
                return !d.has(b) && 4 == d.get(c)
            } catch (v) {
                return !1
            }
        }())return a;
    var d = "$jscomp_hidden_" + Math.random().toString().substring(2);
    e("freeze");
    e("preventExtensions");
    e("seal");
    var g = 0;
    b.prototype.set = function (a, b) {
        c(a);
        if (!x(a, d))throw Error("WeakMap key fail: " + a);
        a[d][this.a] = b;
        return this
    };
    b.prototype.get = function (a) {
        return x(a, d) ? a[d][this.a] : void 0
    };
    b.prototype.has = function (a) {
        return x(a, d) && x(a[d], this.a)
    };
    b.prototype.delete = function (a) {
        return x(a, d) && x(a[d], this.a) ? delete a[d][this.a] : !1
    };
    return b
});
w("Map", function (a) {
    function b() {
        var a = {};
        return a.previous = a.next = a.head = a
    }

    function c(a, b) {
        var c = a.a;
        return t(function () {
            if (c) {
                for (; c.head != a.a;)c = c.previous;
                for (; c.next != c.head;)return c = c.next, {done: !1, value: b(c)};
                c = null
            }
            return {done: !0, value: void 0}
        })
    }

    function e(a, b) {
        var c = b && typeof b;
        "object" == c || "function" == c ? g.has(b) ? c = g.get(b) : (c = "" + ++h, g.set(b, c)) : c = "p_" + b;
        var d = a.c[c];
        if (d && x(a.c, c))for (a = 0; a < d.length; a++) {
            var f = d[a];
            if (b !== b && f.key !== f.key || b === f.key)return {id: c, d: d, index: a, b: f}
        }
        return {id: c, d: d, index: -1, b: void 0}
    }

    function d(a) {
        this.c = {};
        this.a = b();
        this.size = 0;
        if (a) {
            a = u(a);
            for (var c; !(c = a.next()).done;)c = c.value, this.set(c[0], c[1])
        }
    }

    if (function () {
            if (!a || !a.prototype.entries || "function" != typeof Object.seal)return !1;
            try {
                var b = Object.seal({f: 4}), c = new a(u([[b, "s"]]));
                if ("s" != c.get(b) || 1 != c.size || c.get({f: 4}) || c.set({f: 4}, "t") != c || 2 != c.size)return !1;
                var d = c.entries(), e = d.next();
                if (e.done || e.value[0] != b || "s" != e.value[1])return !1;
                e = d.next();
                return e.done || 4 != e.value[0].f || "t" != e.value[1] || !d.next().done ? !1 : !0
            } catch (Y) {
                return !1
            }
        }())return a;
    m();
    p();
    var g = new WeakMap;
    d.prototype.set = function (a, b) {
        var c = e(this, a);
        c.d || (c.d = this.c[c.id] = []);
        c.b ? c.b.value = b : (c.b = {
            next: this.a,
            previous: this.a.previous,
            head: this.a,
            key: a,
            value: b
        }, c.d.push(c.b), this.a.previous.next = c.b, this.a.previous = c.b, this.size++);
        return this
    };
    d.prototype.delete = function (a) {
        a = e(this, a);
        return a.b && a.d ? (a.d.splice(a.index, 1), a.d.length || delete this.c[a.id], a.b.previous.next = a.b.next, a.b.next.previous = a.b.previous, a.b.head = null, this.size--, !0) : !1
    };
    d.prototype.clear = function () {
        this.c = {};
        this.a = this.a.previous = b();
        this.size = 0
    };
    d.prototype.has = function (a) {
        return !!e(this, a).b
    };
    d.prototype.get = function (a) {
        return (a = e(this, a).b) && a.value
    };
    d.prototype.entries = function () {
        return c(this, function (a) {
            return [a.key, a.value]
        })
    };
    d.prototype.keys = function () {
        return c(this, function (a) {
            return a.key
        })
    };
    d.prototype.values = function () {
        return c(this, function (a) {
            return a.value
        })
    };
    d.prototype.forEach = function (a, b) {
        for (var c = this.entries(), d; !(d = c.next()).done;)d = d.value, a.call(b, d[1], d[0], this)
    };
    d.prototype[Symbol.iterator] = d.prototype.entries;
    var h = 0;
    return d
});
w("Set", function (a) {
    function b(a) {
        this.a = new Map;
        if (a) {
            a = u(a);
            for (var b; !(b = a.next()).done;)this.add(b.value)
        }
        this.size = this.a.size
    }

    if (function () {
            if (!a || !a.prototype.entries || "function" != typeof Object.seal)return !1;
            try {
                var b = Object.seal({f: 4}), e = new a(u([b]));
                if (!e.has(b) || 1 != e.size || e.add(b) != e || 1 != e.size || e.add({f: 4}) != e || 2 != e.size)return !1;
                var d = e.entries(), g = d.next();
                if (g.done || g.value[0] != b || g.value[1] != b)return !1;
                g = d.next();
                return g.done || g.value[0] == b || 4 != g.value[0].f || g.value[1] != g.value[0] ? !1 : d.next().done
            } catch (h) {
                return !1
            }
        }())return a;
    m();
    p();
    b.prototype.add = function (a) {
        this.a.set(a, a);
        this.size = this.a.size;
        return this
    };
    b.prototype.delete = function (a) {
        a = this.a.delete(a);
        this.size = this.a.size;
        return a
    };
    b.prototype.clear = function () {
        this.a.clear();
        this.size = 0
    };
    b.prototype.has = function (a) {
        return this.a.has(a)
    };
    b.prototype.entries = function () {
        return this.a.entries()
    };
    b.prototype.values = function () {
        return this.a.values()
    };
    b.prototype.keys = b.prototype.values;
    b.prototype[Symbol.iterator] = b.prototype.values;
    b.prototype.forEach = function (a, b) {
        var c = this;
        this.a.forEach(function (d) {
            return a.call(b, d, d, c)
        })
    };
    return b
});
w("String.prototype.startsWith", function (a) {
    return a ? a : function (a, c) {
        if (null == this)throw new TypeError("The 'this' value for String.prototype.startsWith must not be null or undefined");
        if (a instanceof RegExp)throw new TypeError("First argument to String.prototype.startsWith must not be a regular expression");
        var b = this + "";
        a += "";
        var d = b.length, g = a.length;
        c = Math.max(0, Math.min(c | 0, b.length));
        for (var h = 0; h < g && c < d;)if (b[c++] != a[h++])return !1;
        return h >= g
    }
});
var y = Date.now || function () {
        return +new Date
    };
function z(a) {
    return new Promise(function (b, c) {
        var e = a.length, d = null;
        if (e)for (var g = function (a, f) {
            a || d || (d = f);
            e--;
            e || (d ? c(d) : b())
        }, h = u(a), f = h.next(); !f.done; f = h.next())f.value.then(g.bind(null, !0), g.bind(null, !1));
        else b()
    })
}
function A(a) {
    return self.btoa(String.fromCharCode.apply(null, new Uint8Array(a))).replace(/\+/g, "-").replace(/\//g, "_")
}
;var B = null;
function C(a, b) {
    var c = {};
    c.key = a;
    c.value = b;
    D().then(function (a) {
        return new Promise(function (b, e) {
            var d = a.transaction("swpushnotificationsstore", "readwrite").objectStore("swpushnotificationsstore").put(c);
            d.onsuccess = b;
            d.onerror = e
        })
    })
}
function E(a) {
    return D().then(function (b) {
        return new Promise(function (c, e) {
            var d = b.transaction("swpushnotificationsstore").objectStore("swpushnotificationsstore").get(a);
            d.onsuccess = function () {
                var a = d.result;
                c(a ? a.value : null)
            };
            d.onerror = function () {
                e('Unable to get key "' + a + '" from object store.')
            }
        })
    }).catch(function () {
        return Promise.reject("Unable to open IndexedDB.")
    })
}
function D() {
    return B ? Promise.resolve(B) : new Promise(function (a, b) {
        var c = self.indexedDB.open("swpushnotificationsdb");
        c.onerror = b;
        c.onsuccess = function () {
            var b = c.result;
            if (b.objectStoreNames.contains("swpushnotificationsstore")) B = b, a(B); else return self.indexedDB.deleteDatabase("swpushnotificationsdb"), D()
        };
        c.onupgradeneeded = F
    })
}
function F(a) {
    a = a.target.result;
    a.objectStoreNames.contains("swpushnotificationsstore") && a.deleteObjectStore("swpushnotificationsstore");
    a.createObjectStore("swpushnotificationsstore", {keyPath: "key"})
}
;function G(a) {
    return E("DeviceId").then(function (b) {
        b = H(null, b, null, a);
        return fetch("/notifications_ajax?action_notification_click=1", {
            credentials: "include",
            method: "POST",
            body: b
        })
    })
}
function J() {
    return Promise.all([E("TimestampLowerBound"), K(), E("DeviceId")]).then(function (a) {
        var b = u(a);
        a = b.next().value;
        var c = b.next().value;
        b = b.next().value;
        if (!a)return Promise.reject(null);
        a = H(c, b, a);
        return fetch("/notifications_ajax?action_get_notifications=1", {
            credentials: "include",
            method: "POST",
            body: a
        }).then(L)
    })
}
function L(a) {
    return a.ok ? a.json().then(M).catch(function () {
    }) : Promise.resolve()
}
function M(a) {
    if (a.errors)return Promise.reject(a.errors);
    a.device_id && C("DeviceId", a.device_id);
    a.ts && C("TimestampLowerBound", a.ts);
    if (a.notifications) {
        var b = [];
        a.notifications.forEach(function (a) {
            b.push(self.registration.showNotification(a.title, {
                body: a.message,
                icon: a.iconUrl,
                data: {nav: a.nav, id: a.id, attributionTag: a.attributionTag},
                tag: a.title + a.message + a.iconUrl,
                requireInteraction: !0
            }))
        });
        return z(b).then(function () {
            N(a.display_cap)
        })
    }
    return Promise.resolve()
}
function N(a) {
    -1 != a && self.registration.getNotifications().then(function (b) {
        for (var c = 0; c < b.length - a; c++)b[c].close()
    })
}
function O(a) {
    var b = [P(a), E("RegistrationTimestamp").then(Q), R(), S()];
    Promise.all(b).catch(function () {
        C("IDToken", a);
        T();
        return Promise.resolve()
    })
}
function Q(a) {
    a = a || 0;
    return 9E7 >= y() - a ? Promise.resolve() : Promise.reject()
}
function P(a) {
    return E("IDToken").then(function (b) {
        return a == b ? Promise.resolve() : Promise.reject()
    })
}
function R() {
    return E("Permission").then(function (a) {
        return Notification.permission == a ? Promise.resolve() : Promise.reject()
    })
}
function S() {
    return E("Endpoint").then(function (a) {
        return K().then(function (b) {
            return a == b ? Promise.resolve() : Promise.reject()
        })
    })
}
function T() {
    C("RegistrationTimestamp", 0);
    Promise.all([K(), U(), V()]).then(function (a) {
        var b = u(a);
        a = b.next().value;
        var c = b.next().value;
        b = b.next().value;
        c && (c = A(c));
        b && (b = A(b));
        W(a, c, b)
    }).catch(function () {
        W()
    })
}
function W(a, b, c) {
    a = void 0 === a ? null : a;
    b = void 0 === b ? null : b;
    c = void 0 === c ? null : c;
    C("Endpoint", a);
    C("P256dhKey", b);
    C("AuthKey", c);
    C("Permission", Notification.permission);
    Promise.all([E("DeviceId"), E("NotificationsDisabled")]).then(function (e) {
        var d = u(e);
        e = d.next().value;
        d = d.next().value;
        e = H(a, e, null, null, d, b, c);
        fetch("/notifications_ajax?action_register_device=1", {
            credentials: "include",
            method: "POST",
            body: e
        }).then(X).catch(function () {
        })
    })
}
function H(a, b, c, e, d, g, h) {
    var f = new FormData;
    a && f.append("endpoint", a);
    b && f.append("device_id", b);
    c && f.append("timestamp_lower_bound", c);
    e && (f.append("notification_id", e.id), f.append("attribution_tag", e.attributionTag));
    d && f.append("notifications_disabled", (!!d).toString());
    g && f.append("p256dh_key", g);
    h && f.append("auth_key", h);
    f.append("permission", Notification.permission);
    return f
}
function X(a) {
    C("RegistrationTimestamp", y());
    a.ok && a.json().then(function (a) {
        a.ts && C("TimestampLowerBound", a.ts);
        a.device_id && C("DeviceId", a.device_id)
    }).catch(function () {
    })
}
function K() {
    return self.registration.pushManager.getSubscription().then(function (a) {
        return a ? Promise.resolve(a.endpoint) : Promise.resolve(null)
    })
}
function U() {
    return self.registration.pushManager.getSubscription().then(function (a) {
        return a ? Promise.resolve(a.getKey("p256dh")) : Promise.resolve(null)
    })
}
function V() {
    return self.registration.pushManager.getSubscription().then(function (a) {
        return a ? Promise.resolve(a.getKey("auth")) : Promise.resolve(null)
    })
}
;self.oninstall = function (a) {
    a.waitUntil(self.skipWaiting())
};
self.onactivate = function (a) {
    a.waitUntil(self.clients.claim())
};
self.onmessage = function (a) {
    var b = a.data;
    a = b.type;
    b = b.data;
    "notifications_register" == a ? (C("IDToken", b), T()) : "notifications_check_registration" == a && O(b)
};
self.onnotificationclick = function (a) {
    a.notification.close();
    var b = a.notification.data, c = self.clients.matchAll({type: "window", includeUncontrolled: !0});
    c.then(function (a) {
        a:{
            var c = b.nav;
            a = u(a);
            for (var e = a.next(); !e.done; e = a.next())if (e = e.value, e.url == c) {
                e.focus();
                break a
            }
            self.clients.openWindow(c)
        }
    });
    a.waitUntil(c);
    a.waitUntil(G(b))
};
self.onpush = function (a) {
    a.waitUntil(E("NotificationsDisabled").then(function (a) {
        return a ? Promise.resolve() : J()
    }))
};
self.onpushsubscriptionchange = function () {
    T()
};